
var data=[
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'上报存档',Department:'血液科',Report:'2018-04-16',begin:'2018-04-16',over:'手术麻醉',AOB:'O',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'上报存档',Department:'血液科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'B',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2022-04-16',begin:'2022-04-17',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2022-04-17',begin:'2022-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942698',state:'上报存档',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'},
    {cheak:'<input type="checkbox">',id:'SXBL20180319102942699',state:'提交',Department:'新生儿小婴儿科',Report:'2018-04-16',begin:'2018-04-16',over:'医疗科室',AOB:'A',RDH:'+',antibody:'-'}
]
var page=1;
var count=15;
var tbody=document.querySelector('tbody');
var oPagination = document.querySelector('.pagination');
var oPrevBtn = document.querySelector('.prev')
var oNextBtn = document.querySelector('.next')
var oInputName1=document.querySelector('#InputName1')
var oInputName2=document.querySelector('#InputName2')
var oInputName3=document.querySelector('#InputName3')
var oInputName4=document.querySelector('#InputName4')
var oInputName5=document.querySelector('#InputName5')
var oInputName6=document.querySelector('#InputName6')
var oInputName7=document.querySelector('#InputName7')
var oInputName8=document.querySelector('#InputName8')
var oInputName9=document.querySelector('#InputName9')
var cx=document.querySelector('#cx');
var del=document.querySelector('#del');
del.addEventListener('click',fn8)
function fn8(){
    oInputName1.value='';
    oInputName2.value='---请选择---';
    oInputName3.value='';
    oInputName4.value='';
    oInputName5.value='---请选择---';
    oInputName6.value='';
    oInputName7.value='';
    render();
}
cx.addEventListener('click',fn)
function fn(){
    page=1;
    render()
}
    function render(){
        var str1=oInputName1.value;
        var str2=oInputName2.value;
        var str3=oInputName3.value==''?new Date('2000-8-25').getTime():new Date(oInputName3.value).getTime();
        var str4=oInputName4.value==''?new Date('2000-8-25').getTime():new Date(oInputName4.value).getTime();
        var str5=oInputName5.value;
        var str6=oInputName8.value==''?new Date('2000-8-25').getTime():new Date(oInputName8.value).getTime();
        var str7=oInputName9.value==''?new Date('2000-8-25').getTime():new Date(oInputName9.value).getTime();
        var all=[];
        var data1=[];
        var data2=[];
        var data3=[];
        var data4=[];
        if(str1.trim()==''){
            data1=data;
        }else{
            for(var i=0;i<data.length;i++){
                if(data[i].id.includes(str1)){
                    data1.push(data[i])
                }
            }
        }
        if(str2.trim()=='---请选择---'){
            data2=data1;
        }else{
            for(var i=0;i<data1.length;i++){
                if(data1[i].Department.includes(str2)){
                    data2.push(data1[i])
                }
            }
        }
        if(str3==str6){
            data3 =data2;
        }else{
            for(var i=0;i<data2.length;i++){
                var time=new Date(data2[i].Report).getTime();
                if(time>=str3 && time<=str6){
                    data3.push(data2[i])
                }
            }
        }
        if(str4==str7){
            data4=data3;
        }else{
            for(var i=0;i<data3.length;i++){
                var time2=new Date(data3[i].Report).getTime();
                if(time2>=str4 && time2<=str7){
                    data4.push(data3[i])
                }
            }
        }
        if(str5.trim()=='---请选择---'){
            all=data4;
        }else{
            for(var i=0;i<data4.length;i++){
                if(data4[i].state.includes(str5)){
                    all.push(data4[i])
                }
            }
        }
        tbody.innerHTML='';
        var renderAll=all.slice((page - 1) * count, page * count);
    for(var i=0;i<renderAll.length;i++){
        var tr=document.createElement('tr');
        tr.innerHTML=`<td>${renderAll[i].cheak}</td>
        <td>${renderAll[i].id}</td>
        <td>${renderAll[i].state}</td>
        <td>${renderAll[i].Department}</td>
        <td>${renderAll[i].Report}</td>
        <td>${renderAll[i].begin}</td>
        <td>${renderAll[i].over}</td>
        <td>${renderAll[i].AOB}</td>
        <td>${renderAll[i].RDH}</td>
        <td>${renderAll[i].antibody}</td>`;
        tbody.appendChild(tr);
    }
    var apagebtn=document.querySelectorAll('.pageBtn');
    for(var i=0;i<apagebtn.length;i++){
        oPagination.removeChild(apagebtn[i].parentNode)
    }
for(var i=1;i<=Math.ceil(all.length/count);i++){
    var oli=document.createElement('li');
    oli.innerHTML=`<a class="pageBtn" href="#">${i}</a>`
    if(i==page){
        oli.className='active';
    }
    oPagination.insertBefore(oli,oPagination.lastElementChild);
}
    }
render();
oPagination.addEventListener('click', changePage);
function changePage() {
    if (event.target.className == 'pageBtn') {
        page = event.target.innerText;
        render();
    }
}
oPrevBtn.addEventListener('click', prev);
oNextBtn.addEventListener('click', next);
function prev() {
    if (page > 1) {
        page--;
        render();
    }
}
function next() {
    if (page < Math.ceil(data.length / count)) {
        page++;
        render();
    }
}
var li=document.querySelectorAll('#content li');
var span=document.querySelector('#btn-content');
for(var i=0;i<li.length;i++){
    li[i].onclick=function(){
        span.innerHTML=this.innerHTML;
    }
}
var revise=document.querySelector('#revise');
var divsex=document.querySelector('#tc')
var divkk=$('#block')
var clo=document.querySelector('#clo')
var clo2=document.querySelector('#clo2')
revise.addEventListener('click',fn9)
clo.addEventListener('click',fn0)
clo2.addEventListener('click',fn0)
function fn9(){
    divsex.style.display='block'
    divkk.slideDown();
}
function fn0(){
    divsex.style.display='none'
    divkk.slideUp();
}
 if(localStorage.length==0){
    render()
 }else{
    var arr={cheak:'<input type="checkbox">',id:localStorage.getItem('binli'),state:'提交',Department:localStorage.getItem('keshi'),Report:localStorage.getItem('fashen'),begin:localStorage.getItem('begin'),over:'医疗科室',AOB:localStorage.getItem('AOB'),RDH:localStorage.getItem('RDH'),antibody:'-'}
    data.push(arr)
    render()
 }
 